<template>
  <div class="menu-page">
    <div class="menu-header">
      <h2>主厨推荐</h2>
      <p class="subtitle">精选食材 · 独特烹饪 · 用心呈现</p>
    </div>
    
    <div class="dish-grid">
      <el-card 
        v-for="dish in menu" 
        :key="dish.id" 
        class="dish-card"
        :body-style="{ padding: '0px' }"
      >
        <div class="dish-image-container">
          <img :src="dish.image" :alt="dish.name" class="dish-image">
        </div>
        <div class="dish-info">
          <h3>{{ dish.name }}</h3>
          <p class="description">{{ dish.description }}</p>
          <div class="price-row">
            <span class="price">¥{{ dish.price }}</span>
            <el-button 
              type="primary" 
              class="add-button"
              @click="addToCart(dish)"
            >
              <el-icon><shopping-cart /></el-icon>
              加入购物车
            </el-button>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ShoppingCart } from '@element-plus/icons-vue'
import { useCartStore } from '@/stores/cart'
import type { Dish } from '@/stores/cartStore'

const cartStore = useCartStore()

// 模拟菜单数据
const menu = ref([
  { 
    id: 1, 
    name: '法式牛排', 
    price: 238,
    description: '精选澳洲M5和牛,搭配独特香草黄油,完美火候',
    image: '/src/assets/steak.jpg'
  },
  { 
    id: 2, 
    name: '海鲜意面', 
    price: 168,
    description: '新鲜地中海海鲜,手工制作意大利面,搭配特制番茄酱汁',
    image: '/src/assets/pasta.jpg'
  }
])

const addToCart = (dish: Dish) => {
  cartStore.addItem(dish)
  ElMessage.success('已添加到购物车')
}
</script>

<style scoped lang="scss">
.menu-page {
  padding: 40px 20px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: #fafafa;
}

.menu-header {
  text-align: center;
  margin-bottom: 60px;
  
  h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 16px;
    font-weight: 600;
  }
  
  .subtitle {
    color: #666;
    font-size: 1.1rem;
    letter-spacing: 1px;
  }
}

.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 30px;
  padding: 0 20px;
}

.dish-card {
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  }
}

.dish-image-container {
  height: 220px;
  overflow: hidden;
}

.dish-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  
  &:hover {
    transform: scale(1.05);
  }
}

.dish-info {
  padding: 20px;
  
  h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 10px;
  }
  
  .description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
    height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.price {
  color: #e4393c;
  font-size: 1.4rem;
  font-weight: 600;
  
  &::before {
    content: '¥';
    font-size: 0.8em;
  }
}

.add-button {
  border-radius: 20px;
  padding: 8px 16px;
  
  .el-icon {
    margin-right: 4px;
  }
}

@media (max-width: 768px) {
  .menu-page {
    padding: 20px 10px;
  }
  
  .menu-header {
    margin-bottom: 30px;
    
    h2 {
      font-size: 2rem;
    }
  }
  
  .dish-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 0 10px;
  }
}
</style>